package view;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;

import dao.StuinfoDao;
import entity.StuInfo;

public class MainFrame extends JFrame implements ActionListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private AllShow allShow;
	private StuInfo stuInfo;
    private StuinfoDao stuinfoDao;
	public MainFrame() {
		setTitle("学生信息");
		setSize(800, 600);
		setVisible(true);
		setLocation(300, 100);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setLayout(new BorderLayout());
//		JOptionPane.showMessageDialog(this, "welecome master");
	

		String[] menus = { "菜单", "表格信息", "帮助" };
		String[][] items = { {"退出","刷新" }, {"学生信息表", "学院信息表" }, { "关于" } };
		JMenuBar mb = new JMenuBar();
		for (int i = 0; i < menus.length; i++) {
			JMenu m = new JMenu(menus[i]);
			for (int j = 0; j < items[i].length; j++) {
				JMenuItem item = new JMenuItem(items[i][j]);
				item.addActionListener(this);
				m.add(item);	
			}
			mb.add(m);
		}

		setJMenuBar(mb);
	
		JTabbedPane jp = new JTabbedPane(JTabbedPane.RIGHT);	
		jp.add("全部信息", new AllShow());
		jp.add("查询", new SelectShow());
		jp.add("插入", new InsertShow());
		jp.add("修改", new UpdateShow());
		jp.add("删除", new DeleteShow());
	    add(jp);
	}

	public static void main(String[] args) {

		try {
			UIManager.setLookAndFeel(new NimbusLookAndFeel());
		} catch (UnsupportedLookAndFeelException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				new MainFrame();

			}
		});

	}

	@Override
	public void actionPerformed(ActionEvent e) {
	String cmd=e.getActionCommand();
	switch (cmd) {
	case "退出":
		System.exit(0);
		break;
	case "刷新":
		setVisible(false);
		new MainFrame();	
		break;

	}
		
	}
}
